<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="cn">
<head>
    <meta charset="utf-8">
    <meta content="招聘" http-equiv="keywords">
    <meta name="description" content="招聘,培训">
    <meta name="format-detection" content="telephone=no"><!-- 禁止IPHONE识别手机号码 -->
    <meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
    <meta name="renderer" content="webkit">

    <title>添加日常经费</title>
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/index.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/swiper.min.css}">
    <!-- public_css -->
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/public_lib.css}">
    <!-- zy_public_css -->
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/zy_public.css}">
    <!-- 子页css -->
    <link rel="stylesheet" type="text/css" th:href="@{/asserts/css/children.css}">
    <!-- js -->
    <script type="text/javascript" th:src="@{/asserts/js/jquery-3.3.1.min.js}"></script>
    <script type="text/javascript" th:src="@{/asserts/js/swiper.min.js}"></script>
    <script type="text/javascript" th:src="@{/asserts/js/public.js}"></script>
    <script th:src="@{/asserts/Apolar_sh/lib/layer/2.4/layer.js}"></script>

</head>
<body>
<header class="zy_search_top_box scroll_fix">
    <div class="zy_title_top fix">
        <div class="one" href="javascript:" onclick="history.back();"><img th:src="@{/asserts/images/back_jt.png}">
            <a th:href="@{dsShow(currentPage=${currentPage},pageSize=${pageSize})}"
               style="color: #FFFFFF;"><span>返回</span></a>
        </div>
        <h1>添加日常经费</h1>

    </div>
</header>

<!-- 内容框 -->
<div class="zy_module-content zy_vip_conbox">
    <div class="zy_vip_scbox zy_vip_myfabu bgwh">

        <div class="sc_list vip_user_info_mima vip_user_createbox">
            <form id="addForm">
                <div class="write" style="margin-top: 10%">
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;*&nbsp;</a><span>发生日期：</span><input th:id="dsDate" type="date" id="dsDate"
                                                                                                name="dsDate"></label>
                    </div>
                </div>
                <div class="write" style="margin-top: 10%">
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>交通打车:</span><input id="dsTrafficTaxi" type="number"
                                                                                                           name="dsTrafficTaxi"
                                                                                                           placeholder="请输入打车(滴滴)费用"
                                                                                                           onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>交通其它：</span><input id="dsTrafficOther" type="number"
                                                                                                           name="dsTrafficOther"
                                                                                                           placeholder="请输入其他的交通费用"
                                                                                                           onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>总交通费：</span><input id="dsTrafficTotal" type="number"
                                                                                                           name="dsTrafficTotal"
                                                                                                           placeholder="请输入交通费-合计"
                                                                                                           onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                </div>
                <div class="write" style="margin-top: 10%">
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>住宿费：</span><input id="dsStayTotalprice" type="number"
                                                                                                          name="dsStayTotalprice"
                                                                                                          placeholder="请输入住宿费"
                                                                                                          onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>住宿间数：</span><input id="dsStayCount" type="number"
                                                                                                           name="dsStayCount"
                                                                                                           placeholder="请输入住宿间数"
                                                                                                           onchange="if(/\D/g.test(value)){layer.msg('格式不对哦!请输入整数', {icon: 0, time: 1500});value='';}"></label>
                    </div>
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>住宿人：</span><input id="dsStayPeople" type="text"
                                                                                                          name="dsStayPeople"
                                                                                                          placeholder="请输入人名,逗号隔开,同性必须合住"
                                                                                                          onchange="if(/[\d]/g.test(value)){layer.msg('格式不对哦!请输入字母或中文', {icon: 0, time: 1500});value='';}"></label>
                    </div>
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>住宿单价：</span><input id="dsStayUnitprice" type="number"
                                                                                                           name="dsStayUnitprice"
                                                                                                           placeholder="请输入住宿单价"
                                                                                                           onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                </div>
                <div class="write" style="margin-top: 10%">
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>学生招待：</span><input id="dsEntertainStu" type="number"
                                                                                                           name="dsEntertainStu"
                                                                                                           placeholder="请输入学生招待费用"
                                                                                                           onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>领导招待：</span><input id="dsEntertainLeader" type="number"
                                                                                                           name="dsEntertainLeader"
                                                                                                           placeholder="请输入领导招待费用"
                                                                                                           onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                </div>
                <div class="write" style="margin-top: 10%">
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>劳务/佣金：</span><input id="dsServices"
                                type="number" name="dsServices" placeholder="请输入劳务/佣金费用"
                                onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                </div>
                <div class="write" style="margin-top: 10%">
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>其它费用：</span><input id="dsOther" type="number"
                                                                                                           name="dsOther"
                                                                                                           placeholder="请输入其它费用"
                                                                                                           onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>其它说明</span><textarea
                                name="dsOtherState" placeholder="请填写关于其它费用的说明..."></textarea></label>
                    </div>
                </div>
                <div class="write" style="margin-top: 10%">
                    <div class="form_line bbd xzbox work_style">
                        <span><a style="color: red;">&nbsp;*&nbsp;</a>员工：</span>
                        <select name="dsSellerUid" id="dsSellerUid">
                            <option disabled value="" selected>--请选择员工--</option>
                            <option th:each="seller:${sellerList}"
                                    th:value="${seller.uid}"
                                    th:selected="${seller.uid==session.user.uid}">[[${seller.personname }]]
                            </option>
                        </select>
                    </div>
                </div>
                <div class="write" style="margin-top: 10%">
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;*&nbsp;</a><span>小计</span><input type="number" id="dsTotal"
                                                                                             name="dsTotal"
                                                                                             placeholder="必填字段，请输入小计"
                                                                                             onchange="if(/\D/.test(value)){layer.msg('格式不对哦!请输入数字', {icon: 0, time: 1500});value='';}"><a>元</a></label>
                    </div>
                </div>
                <div class="write" style="margin-top: 10%">
                    <div class="form_line">
                        <label><a style="color: red;">&nbsp;&nbsp;&nbsp;&nbsp;</a><span>备注</span><textarea
                                name="dsRemark" placeholder="填写备注信息..."></textarea></label>
                    </div>
                    <a style="display: block" class="zy_butn bord_3"
                       th:onclick="submit([[${currentPage}]],[[${pageSize}]])">保存</a>
                </div>
            </form>
        </div>

    </div>

</div>
<!-- 底部导航 -->
<div class="foot_menu">
    <ul>
        <li><a th:href="@{/mcampus/findAll}"> <i><img
                th:src="@{/asserts/images/menu_icon01.png}"></i> <span>信息采集</span> </a>
        </li>
        <li><a th:href="@{/mcampusVisit/findAll}"> <i><img
                th:src="@{/asserts/images/menu_icon02.png}"></i>
            <span>拜访记录</span> </a></li>
        <li><a th:href="@{/mTraining/list}"> <i><img
                th:src="@{/asserts/images/menu_icon03.png}"></i>
            <span>实训订单</span></a></li>
        <li><a style="color: #00caff" th:href="@{/mds/dsShow}"> <i><img
                th:src="@{/asserts/images/menu_icon04.png}"></i>
            <span>日常经费</span> </a></li>
    </ul>
</div>
<script>

    $("#dsTrafficTotal").focus(trafficTotal)

    function trafficTotal() {
        var dsTrafficTaxi = $("#dsTrafficTaxi").val();
        var dsTrafficOther = $("#dsTrafficOther").val();
        if (dsTrafficTaxi === '') {
            dsTrafficTaxi = 0;
        }
        if (dsTrafficOther === '') {
            dsTrafficOther = 0;
        }
        document.getElementById("dsTrafficTotal").value = parseFloat(dsTrafficTaxi) + parseFloat(dsTrafficOther);
    }
    $("#dsTotal").focus(total)
    function total() {
        var dsStayTotalprice = $("#dsStayTotalprice").val();
        var dsEntertainStu = $("#dsEntertainStu").val();
        var dsEntertainLeader = $("#dsEntertainLeader").val();
        var dsServices = $("#dsServices").val();
        var dsOther = $("#dsOther").val();
        var dsTrafficTaxi = $("#dsTrafficTaxi").val();
        var dsTrafficOther = $("#dsTrafficOther").val();
        if (dsTrafficTaxi === '') {
            dsTrafficTaxi = 0;
        }
        if (dsTrafficOther === '') {
            dsTrafficOther = 0;
        }
        if (dsStayTotalprice === '') {
            dsStayTotalprice = 0;
        }
        if (dsEntertainStu === '') {
            dsEntertainStu = 0;
        }
        if (dsEntertainLeader === '') {
            dsEntertainLeader = 0;
        }
        if (dsServices === '') {
            dsServices = 0;
        }
        if (dsOther === '') {
            dsOther = 0;
        }
        document.getElementById("dsTotal").value = parseFloat(dsTrafficTaxi) + parseFloat(dsTrafficOther) + parseFloat(dsStayTotalprice) + parseFloat(dsEntertainStu) + parseFloat(dsEntertainLeader) + parseFloat(dsServices) + parseFloat(dsOther);
    }

    function submit() {
        var dsDate = $("#dsDate").val();
        var dsSellerUid = $("#dsSellerUid").val();
        var dsTotal = $("#dsTotal").val();
        console.log(dsDate, dsSellerUid, dsTotal)
        if (dsDate == null || dsDate === "") {
            layer.msg('亲，日期不能为空哦!', {
                icon: 0,
                time: 1500
            });
        } else if (dsSellerUid == null || dsSellerUid === "") {
            layer.msg('亲，请选择员工哦!', {
                icon: 0,
                time: 1500
            });
        } else if (dsTotal == null || dsTotal === "") {
            layer.msg('亲，小计不能为空哦!', {
                icon: 0,
                time: 1500
            });
        } else {
            trafficTotal();
            total();
            $.ajax({
                type: 'POST',
                url: './dsAdd',
                data: $("#addForm").serialize(),
                success: function (data) {
                    if (data.id === 0) {
                        layer.msg(data.data, {
                            icon: 1,
                            time: 500
                        });
                        setTimeout(function () {
                            location.replace('[[${#httpServletRequest.getContextPath()}]]' + '/mds/dsShow');
                        }, 500);
                    } else {
                        layer.msg(data.data, {
                            icon: 0,
                            time: 2000
                        });
                    }
                },
                error: function (data) {
                    console.log(data.msg);
                }
            })
        }
    }
</script>
</body>
</html>
